home *** CD-ROM | disk | FTP | other *** search
- Path: library.erc.clarkson.edu!rpi!not-for-mail
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: I don't believe it! Weird thing about Virtual tables
- Date: 17 Apr 1996 23:12:26 -0000
- Organization: Datalytics, Inc.
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: herbs@connobj.com
- Message-ID: <4l3tsq$c08@netlab.cs.rpi.edu>
- References: <4ku0ee$hjj@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Wed, 17 Apr 1996 00:00:21 -0400
-
- Rodrigo de Salvo Braz wrote:
- [snip]
- > The virtual table of one of my classes (say, Dog) is initialized by
- > code!
- >
- > It sounds ok at first, but since each module has its own initializing
- > code (for global variables and similar stuff), I have Dog's virtual
- > table initialized AFTER initializing code of modules located BEFORE
- > Dog's module in the Project definition. Since I have variables using
- > Dog in those earlier modules, I get a real crash![snip]
- > Am doing any mistake on it? Is there any option preventing it? Why
- > doesn't the compiler create the virtual tables already initialized?
- >
-
- It sounds as though you are using static Dogs. Since the
- initialization order of statics are not guaranteed, the static
- Dogs used in your other translation units may not be initialized
- by the time you use them.
-
- One workaround for this is to declare the static Dogs in the
- function where they're needed, or to declare them in a function
- that can then provide them to the others.
-
- --
- Rob Stewart | My opinions are generally my own. They do
- Datalytics, Inc.| not necessarily reflect those of my employer.
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-